package everyday;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class T1487 {
    public String[] getFolderNames(String[] names) {
        String[] res = new String[names.length];
        Map<String,Integer> hash = new HashMap<>();
        for (int i = 0; i < names.length; i++) {
            if (hash.containsKey(names[i])){
                int sum=hash.get(names[i])+1;
                String str1=names[i]+"("+sum+")";
                while(hash.containsKey(str1)){
                    sum++;
                    str1=names[i]+"("+sum+")";
                }
                res[i]=str1;
                hash.put(str1,0);
                hash.put(names[i],sum);
            }else {
                res[i]=names[i];
                hash.put(names[i],0);
            }
        }
        return res;
    }
}
